package org.example.design.search;

/**
 * @Auther:Liu
 * @Testname:LotteryBuyerObserver
 * @Date:2025/8/15 11:43
 */
public class LotteryBuyerObserver implements Observer {

    private int number;
    private String name;

    public LotteryBuyerObserver(String name) {
        this.number = (int) (Math.random() * 33 + 1);
        this.name = name;
    }

    @Override
    public void update(int number) {
        System.out.println("开奖了，中奖号码是：" + number);
        System.out.println(name + "买的号码是：" + this.number);
        System.out.println(this.number == number ? name + "中奖了" : "很遗憾，" + name + "没有中奖");
    }
}